package com.base.mine;

import android.text.TextUtils;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.base.commonlib.base.BaseApp;
import com.base.commonlib.base.CBaseBarMvpActivity;
import com.base.commonlib.bean.User;
import com.base.commonlib.utils.RxBus2;
import com.base.mine.databinding.ActivityMorecenterintroBinding;

import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
 * Created by weikailiang on 2020/3/19.
 */
@Route(path = "/mine/morecenterintro")
public class MoreCenterIntroActivity extends CBaseBarMvpActivity{
    private ActivityMorecenterintroBinding mBinding;
    @Override
    protected int getLayoutResource() {
        return R.layout.activity_morecenterintro;
    }

    @Override
    protected void init() {
        super.init();
        mBinding = (ActivityMorecenterintroBinding) mRootBinding;
        setBackNavigation();
        setBarTitle("更多设置");
        Disposable disposable1 = RxBus2.getInstance().doSubscribe(User.class, new Consumer<User>() {
            @Override
            public void accept(User user) throws Exception {
                mBinding.userSex.setText(user.getGender()==1?"男":"女");
                mBinding.userBirthday.setText(user.getBirthday());
            }
        });
        RxBus2.getInstance().addSubscription(this, disposable1);

        if (BaseApp.getUser()!=null) {
            if (BaseApp.getUser().getGender()!=null) {
                mBinding.userSex.setText(BaseApp.getUser().getGender() == 1 ? "男" : "女");
            }
            if (BaseApp.getUser().getBirthday()!=null) {
                mBinding.userBirthday.setText(BaseApp.getUser().getBirthday());
            }
        }
    }

    @Override
    protected void start() {
        mBinding.rlSex.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/mine/infomodify")
                        .withInt("type",1)
                        .withString("title","修改性别").navigation();
            }
        });
        mBinding.rlBirthday.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/mine/infomodify")
                        .withInt("type",2)
                        .withString("title","修改生日").navigation();
            }
        });
    }
}
